<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>{$current['title']}-{$Think.CONFIG.sitename}</title>

    <link href="__PUBLIC__/static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__PUBLIC__/static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/static/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/static/css/animate.min.css" rel="stylesheet">
    <include file="Public/commoncss" />
    <link href="__PUBLIC__/static/css/plugins/jedate/jedate.css" rel="stylesheet">
</head>

<body class="gray-bg top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom white-bg">
            <include file="Public/header" />
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-3">
                    <div class="ibox float-e-margins">
                        <include file="Public/worknav" />
                    </div>
                </div>
                <div class="col-sm-9 animated fadeInRight">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>{$user.name}的<small>工作报表</small></h5>
                        </div>
                        <div class="ibox-content">
                            <form class="form-horizontal m-t" action="{:U('update')}" id="myForm">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">相关时间</label>
                                    <div class="col-sm-2">
                                        <input class="form-control inputxt" name="date" type="text" id="date" placeholder=" 日 期 " datatype="*10-10" nullmsg="不能为空" errormsg="不能为空" sucmsg="验证通过！" autocomplete="off">
                                        <span class="help-block m-b-none Validform_checktip"></span>
                                    </div>
                                    <div class="col-sm-2">
                                        <input class="form-control inputxt" name="start" type="text" id="start" placeholder="开始时间" datatype="*5-5" nullmsg="不能为空" errormsg="不能为空" sucmsg="验证通过！" autocomplete="off">
                                        <span class="help-block m-b-none Validform_checktip"></span>
                                    </div>
                                    <div class="col-sm-2">
                                        <input class="form-control inputxt" name="end" type="text" id="end" placeholder="结束时间" datatype="*5-5" nullmsg="不能为空" errormsg="不能为空" sucmsg="验证通过！" autocomplete="off">
                                        <span class="help-block m-b-none Validform_checktip"></span>
                                    </div>
                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">工作类型：</label>

                                    <div class="col-sm-2">

                                        <select class="form-control m-b" name="sect1">
                                            <option>请选择</option>
                                            <volist name="sect" empty="null" id="vo">
                                                <option value="{$vo.id}">{$vo.name}</option>
                                            </volist>
                                        </select>
                                    </div>
                                    <div class="col-sm-2">
                                        <select class="form-control m-b" name="sect2">
                                            <option>请选择</option>

                                        </select>
                                    </div>
                                    <div class="col-sm-2">
                                        <select class="form-control m-b" name="sect3">
                                            <option>请选择</option>

                                        </select>

                                    </div>
                                    <div class="col-sm-2">
                                        <input type="hidden" name="rid" value="" datatype="*" nullmsg="请选择类型！" errormsg="请选择工作类型！">
                                        <span class="help-block m-b-none Validform_checktip"></span>
                                    </div>
                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">工作说明：</label>
                                    <div class="col-sm-7">
                                        <textarea name="content" id="" cols="30" rows="5" style="resize: none;width:100%;"  datatype="*" nullmsg="请填写工作说明！" errormsg="不超过100字！" maxlength="100"></textarea>
                                        <span class="help-block m-b-none">（必须填写说明，不超过100字）</span>
                                        <span class="help-block m-b-none Validform_checktip"></span>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button class="btn btn-primary" type="submit">保存内容</button>
                                        <a class="btn btn-white" href="{:U('Work/index')}">取消</a>
                                        <span class="help-block m-b-none Validform_checktip" id="dump"></span>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <include file="Public/footer" />
    </div>
</div>
<include file="Public/commonjs" />
<script src="__PUBLIC__/static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__PUBLIC__/static/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/static/js/plugins/jedate/jquery.jedate.min.js"></script>
<script src="__PUBLIC__/static/js/plugins/validate/Validform_v5.3.2.js"></script>
<script>
        jeDate({dateCell:'#date',isinitVal:true,isTime:false,skinCell:"jedategreen", format: 'YYYY-MM-DD',maxDate: jeDate.now(31)});
        jeDate({dateCell:'#start',isinitVal:false,isTime:false,skinCell:"jedategreen", format: 'hh:mm'});
        jeDate({dateCell:'#end',isinitVal:false,isTime:false,skinCell:"jedategreen", format: 'hh:mm'});
        $(function(){
           //写入select
            $("select[name='sect1']").change(function(){
                var strvalue=$(this).children('option:selected').val();
                $.ajax({
                    url: "{:U('getSect')}",
                    type: "POST",
                    dataType: "json",
                    data:{pid:strvalue},//传入数据
                    success:(function(msg){
                        $("select[name='sect2']").html('');
                        $("select[name='sect3']").html('');
                        if(jQuery.isEmptyObject(msg)){
                            $("select[name='sect2']").append('<option value=0 >'+"请选择"+'</option>');
                            $("select[name='sect3']").append('<option value=0 >'+"请选择"+'</option>');
                            $("input[name='rid']").val(strvalue);
                        }else{
                            $("select[name='sect2']").append('<option value=0 >'+"请选择"+'</option>');
                            $("select[name='sect3']").append('<option value=0 >'+"请选择"+'</option>');
                            $.each(msg,function(index,val){
                                $("select[name='sect2']").append('<option value='+val.id+' >'+val.name+'</option>');})
                        }
                    })
                });
            });
            $("select[name='sect2']").change(function(){
                var strvalue=$(this).children('option:selected').val();
                $.ajax({
                    url: "{:U('getSect')}",
                    type: "POST",
                    dataType: "json",
                    data:{pid:strvalue},//传入数据
                    success:(function(msg){
                        $("select[name='sect3']").html('');
                        if(jQuery.isEmptyObject(msg)){
                            $("select[name='sect3']").append('<option value=0 >'+"请选择"+'</option>');
                            $("input[name='rid']").val(strvalue);
                        }else{
                            $("select[name='sect3']").append('<option value=0 >'+"请选择"+'</option>');
                            $.each(msg,function(index,val){
                                $("select[name='sect3']").append('<option value='+val.id+' >'+val.name+'</option>');})
                        }
                    })
                });
            });

            $("select[name='sect3']").change(function() {
                var strvalue=$(this).children('option:selected').val();
                if(strvalue){
                    $("input[name='rid']").val(strvalue);
                    return true;
                }
            });

            //提交表单
            $("#myForm").Validform({
                tiptype:function(msg,o,cssctl){
                    if(!o.obj.is("form")){
                        var objtip=o.obj.siblings(".Validform_checktip");
                        cssctl(objtip,o.type);
                        objtip.text(msg);
                    }else{
                        if(msg == '恭喜,操作成功！'){
                            window.location.href="{:U('Work/index')}";
                        }else{
                            var objtip=o.obj.find("#dump");
                            cssctl(objtip,o.type);
                            objtip.text(msg);
                        }
                    }
                },
                ajaxPost:true
            });
        });
</script>

</body>

</html>